package bairui.international.model.domain.jpa;

import com.lianjing.sh.model.uml.model.data.TBSuper_BaseTimeAndOrderValue;

/**
 *
 * (首页模块产品)TB_IndexModuleProduct
 *
 * @说明
 * <pre>

 * </pre>
 *
 * @see Help_TB_IndexModuleProduct#inheritance() 继承体系信息
 *
 */
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate

@javax.persistence.Entity(name="t_indexModuleProduct")
@com.lianjing.sh.processing.info.annotation.GenerateInfoModel
@SuppressWarnings("serial")
@com.lianjing.sh.model.common.annotation.Comment("首页模块产品")
@com.lianjing.sh.processing.info.annotation.InfoComment("首页模块产品")
public class TB_IndexModuleProduct
 extends TBSuper_BaseTimeAndOrderValue
 implements 
	com.lianjing.sh.model.common.stardard.TableModel<bairui.international.model.domain.jpa.id.ID_IndexModuleProduct>,
	com.sh_lianjing.state.HasStatable,
	java.io.Serializable

{

	
	
	/**
	 * 必须属性赋值接口
	 */
	public static interface MustProperties{
		public bairui.international.model.domain.jpa.id.ID_IndexModuleProduct getId();
		/** 状态 */
		public com.lianjing.sh.model.uml.model.status.State_UpDown getState();
	}
	
	/**
	 * 为必须属性赋值
	 */
	public TB_IndexModuleProduct properties(MustProperties properties) {
		this.setId(properties.getId());
		this.setState(properties.getState());
		return this;
	}
	
	/**
	 *	必须属性构造函数
	 */
	public TB_IndexModuleProduct(MustProperties properties) {
		this.properties(properties);
	}
	
	
	/**
	 * 可选单属性赋值接口
	 */
	public static interface OptionalSingleProperties{
		/** 说明 */
		public String getComment();
	}
	
	/**
	 * 为可选单属性赋值
	 */
	public TB_IndexModuleProduct properties(OptionalSingleProperties properties) {
		this.setComment(properties.getComment());
		return this;
	}
	
	
	
	public TB_IndexModuleProduct(MustProperties must, OptionalSingleProperties optionalSingle) {
		this.properties(must);
		this.properties(optionalSingle);
	}
	
	/**
	 * 仅当前必须属性赋值接口
	 */
	public static interface CurrentMustProperties{
		public bairui.international.model.domain.jpa.id.ID_IndexModuleProduct getId();
		/** 状态 */
		public com.lianjing.sh.model.uml.model.status.State_UpDown getState();
	}
	
	/**
	 * 为仅当前必须属性赋值
	 */
	public TB_IndexModuleProduct properties(CurrentMustProperties properties) {
		this.setId(properties.getId());
		this.setState(properties.getState());
		return this;
	}
	
	/**
	 * 仅当前可选单属性赋值接口
	 */
	public static interface CurrentOptionalSingleProperties{
		/** 说明 */
		public String getComment();
	}
	
	/**
	 * 为仅当前可选单属性赋值
	 */
	public TB_IndexModuleProduct properties(CurrentOptionalSingleProperties properties) {
		this.setComment(properties.getComment());
		return this;
	}
	
	public TB_IndexModuleProduct(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseTimeAndOrderValue bean,
		CurrentMustProperties mustProperties,
		CurrentOptionalSingleProperties optionalProperties
	) {
		this(bean);
		this.properties(mustProperties);
		this.properties(optionalProperties);
	}
	
	public TB_IndexModuleProduct(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseTimeAndOrderValue bean
	) {
		update(bean);
	}
	
	public TB_IndexModuleProduct update(com.lianjing.sh.model.uml.model.data.TBSuper_BaseTimeAndOrderValue bean){
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		return this;
	}
	
	
	/**
	 * 更新属性内部类
	 */
	public abstract class UpdateProperties {
	
		public UpdateProperties() throws Exception {
			Integer orderValue = getOrderValue(TB_IndexModuleProduct.this);
			if(isOverride_getOrderValue){
				TB_IndexModuleProduct.this.setOrderValue(orderValue);
			}
	
			bairui.international.model.domain.jpa.TB_Product product = getProduct(TB_IndexModuleProduct.this);
			if(isOverride_getProduct){
				TB_IndexModuleProduct.this.setProduct(product);
			}
	
			bairui.international.model.domain.jpa.TB_IndexModule indexModule = getIndexModule(TB_IndexModuleProduct.this);
			if(isOverride_getIndexModule){
				TB_IndexModuleProduct.this.setIndexModule(indexModule);
			}
	
			String comment = getComment(TB_IndexModuleProduct.this);
			if(isOverride_getComment){
				TB_IndexModuleProduct.this.setComment(comment);
			}
	
			com.lianjing.sh.model.uml.model.status.State_UpDown state = getState(TB_IndexModuleProduct.this);
			if(isOverride_getState){
				TB_IndexModuleProduct.this.setState(state);
			}
		}
	
		public TB_IndexModuleProduct up(){
			return TB_IndexModuleProduct.this;
		}
	
		/** 排序值 */
		private boolean isOverride_getOrderValue = true;
		public Integer getOrderValue(TB_IndexModuleProduct it) throws Exception { 
			isOverride_getOrderValue = false; 
			return null;
		}
		/** 产品 */
		private boolean isOverride_getProduct = true;
		public bairui.international.model.domain.jpa.TB_Product getProduct(TB_IndexModuleProduct it) throws Exception { 
			isOverride_getProduct = false; 
			return null;
		}
		/** 首页模块 */
		private boolean isOverride_getIndexModule = true;
		public bairui.international.model.domain.jpa.TB_IndexModule getIndexModule(TB_IndexModuleProduct it) throws Exception { 
			isOverride_getIndexModule = false; 
			return null;
		}
		/** 说明 */
		private boolean isOverride_getComment = true;
		public String getComment(TB_IndexModuleProduct it) throws Exception { 
			isOverride_getComment = false; 
			return null;
		}
		/** 状态 */
		private boolean isOverride_getState = true;
		public com.lianjing.sh.model.uml.model.status.State_UpDown getState(TB_IndexModuleProduct it) throws Exception { 
			isOverride_getState = false; 
			return null;
		}
	
	}
	
	
	/**
	 * 构造函数
	 */
	public TB_IndexModuleProduct() {
	}
	
	public TB_IndexModuleProduct(
		@lombok.NonNull bairui.international.model.domain.jpa.id.ID_IndexModuleProduct id
	) {
		this.setId(id);
	}
	
	public TB_IndexModuleProduct(
		@lombok.NonNull TB_IndexModuleProduct bean
	) {
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		this.setProduct(bean.getProduct());
		this.setIndexModule(bean.getIndexModule());
		this.setComment(bean.getComment());
		this.setState(bean.getState());
	}
	
	

	/**
	 * 联合主键
	 */
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.EmbeddedId
	@org.hibernate.annotations.Target(bairui.international.model.domain.jpa.id.ID_IndexModuleProduct.class)
	private bairui.international.model.domain.jpa.id.ID_IndexModuleProduct id;
	
	@com.fasterxml.jackson.databind.annotation.JsonSerialize(using=bairui.international.model.domain.jpa.id.ID_IndexModuleProduct.CompositePKSerializer.class)
	public bairui.international.model.domain.jpa.id.ID_IndexModuleProduct getId() {
		return this.id;
	}
	public void setId(bairui.international.model.domain.jpa.id.ID_IndexModuleProduct id) {
		this.id = id;
		if(null != this.id){
			this.setProduct(this.id.getProduct());
			this.setIndexModule(this.id.getIndexModule());
		}
	}
	public void setId_only(bairui.international.model.domain.jpa.id.ID_IndexModuleProduct id) {
		this.id = id;
	}
	


	/**
	 * 属性
	 */
	@com.lianjing.sh.model.common.annotation.Comment("产品")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	@javax.persistence.JoinColumn(insertable=false, updatable=false)
	private bairui.international.model.domain.jpa.TB_Product product;

	@com.lianjing.sh.model.common.annotation.Comment("首页模块")
	@com.lianjing.sh.processing.info.annotation.InfoComment("首页模块")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	@javax.persistence.JoinColumn(insertable=false, updatable=false)
	private bairui.international.model.domain.jpa.TB_IndexModule indexModule;

	@com.lianjing.sh.model.common.annotation.Comment("说明")
	@com.lianjing.sh.processing.info.annotation.InfoComment("说明")
	@javax.persistence.Column(name="comment", length=255)
	private String comment;

	@com.lianjing.sh.model.common.annotation.Comment("状态")
	@com.lianjing.sh.processing.info.annotation.InfoComment("状态")
	@javax.persistence.Enumerated(javax.persistence.EnumType.STRING)
	@javax.persistence.Column(name="state", nullable=false)
	private com.lianjing.sh.model.uml.model.status.State_UpDown state;

	/** get[产品] */
	public bairui.international.model.domain.jpa.TB_Product getProduct() {
		return this.product;
	}

	/** get[首页模块] */
	public bairui.international.model.domain.jpa.TB_IndexModule getIndexModule() {
		return this.indexModule;
	}

	/** get[说明] */
	public String getComment() {
		return this.comment;
	}

	/** get[状态] */
	public com.lianjing.sh.model.uml.model.status.State_UpDown getState() {
		return this.state;
	}

	/** set[产品] */
	public void setProduct(bairui.international.model.domain.jpa.TB_Product product) {
		this.product = product;
	}

	/** set[首页模块] */
	public void setIndexModule(bairui.international.model.domain.jpa.TB_IndexModule indexModule) {
		this.indexModule = indexModule;
	}

	/** set[说明] */
	public void setComment(String comment) {
		this.comment = comment;
	}

	/** set[状态] */
	public void setState(com.lianjing.sh.model.uml.model.status.State_UpDown state) {
		this.state = state;
	}

	public void assignProduct(bairui.international.model.domain.jpa.TB_Product product) {
		if(null != product){
			product.addIndexModuleProducts(this);
		}
		this.setProduct(product);
	}
	

	public void assignIndexModule(bairui.international.model.domain.jpa.TB_IndexModule indexModule) {
		if(null != indexModule){
			indexModule.addIndexModuleProducts(this);
		}
		this.setIndexModule(indexModule);
	}
	

	
	
	

	/** take[产品] */
	public bairui.international.model.domain.jpa.TB_Product takeProduct(){
		if(null == this.product){
			this.product = new bairui.international.model.domain.jpa.TB_Product();
		}
		return this.product;
	}
	
	/** take[首页模块] */
	public bairui.international.model.domain.jpa.TB_IndexModule takeIndexModule(){
		if(null == this.indexModule){
			this.indexModule = new bairui.international.model.domain.jpa.TB_IndexModule();
		}
		return this.indexModule;
	}
	
	/** must[产品] */
	public bairui.international.model.domain.jpa.TB_Product mustProduct() {
		return this.product;
	}
	
	/** must[首页模块] */
	public bairui.international.model.domain.jpa.TB_IndexModule mustIndexModule() {
		return this.indexModule;
	}
	
	

	/**
	 * 复写 hashCode
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		return prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
	}
	
	/**
	 * 复写 equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		TB_IndexModuleProduct other = (TB_IndexModuleProduct) obj;
		if (this.getId() == null) {
			return false;
		} else if (!this.getId().equals(other.getId())){
			return false;
		}
		return true;
	}
	

	/**
	 * 用来覆盖toString()的输出
	 */
	@javax.persistence.Transient
	private String toString;
	
	public void setToString(String toString) {
		this.toString = toString;
	}
	
	/**
	 * 复写 toString
	 */
	@Override
	public String toString() {
		if(null != this.toString){
			return this.toString;
		}
		return super.toString();
	}	

	@javax.persistence.PrePersist
	public void prePersist() {
		this.setCreateTime(new java.util.Date());
		this.setModifyTime(new java.util.Date());
	}
	
	@javax.persistence.PreUpdate
	public void preUpdate() {
		this.setModifyTime(new java.util.Date());
	}

	/**
	 * 状态相关
	 */
	public com.lianjing.sh.model.uml.model.status.State_UpDown state(){
		return this.getState();
	}


}
